<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <script src="../../layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../layuimini/css/public.css" media="all">
    <script src="../../layuimini/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
    <style>
        body {
            background-color: #ffffff;
        }
        #box{
            margin-left: 25px;
            margin-top: 25px;
            width: 500px;
            height: 450px;
            box-shadow: 0 0 3px #ccc;
        }
        #box-form{
            height: 400px;
            margin: 0 auto;
            width: 350px;
            padding-top: 25px;
        }
    </style>
</head>
<body>
<div id="box">
    <form id="box-form" class="layui-form" action="" th:object="${area}">


        <div class="layui-form-item">
            <label class="layui-form-label">编号</label>
            <div class="layui-input-inline">
                <input disabled id="stuNo" type="text" th:field="*{tId}" required  lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <!-- 提示信息 -->
            <div id="exist-stu" class="layui-form-mid layui-word-aux"></div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">省</label>
            <div class="layui-input-inline">
                <input type="text" th:field="*{tProvince}" required lay-verify="required" placeholder="请输入省" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">市</label>
            <div class="layui-input-inline">
                <input type="text" th:field="*{tCity}" required lay-verify="required" placeholder="请输入市" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">县/区</label>
            <div class="layui-input-inline">
                <input type="text" th:field="*{tCounty}" required lay-verify="required" placeholder="请输入县/区" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">详细地址描述</label>
            <div class="layui-input-inline">
                <input type="text" th:field="*{tDetailed}" required lay-verify="required" placeholder="请输入详细地址" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" id="btn-edit" lay-submit lay-filter="formDemo">修改</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>

<script>
    layui.use('form', function(){
        var form = layui.form;
        var $ = layui.$;

        //监听提交
        form.on('submit(formDemo)', function(data){
            $("#btn-edit").attr("disabled","disabled").addClass("layui-btn-disabled");
            data = data.field;
            //异步发送修改请求
            $.post("/area/updateArea",data,function (res){
                if(res.code == 0){
                    layer.msg('修改成功!',{time: 1000, icon: 1},function (){
                        //刷新表格
                        parent.refreshTable();
                        //关闭窗口
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                }else{
                    $("#btn-edit").removeAttr("disabled","disabled").removeClass("layui-bth-disabled");
                    layer.msg('修改失败',{time: 1000, icon: 4});
                }
            });
            return false;
        });
    });
</script>
</body>
</html>